
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mytools;

import com.opensymphony.xwork2.ActionSupport;
import java.util.List;

/**

 *

 * @author wl

 */
public class choiceoperation extends ActionSupport {

    private int id;
    private String[] ids;
    private String subject;
    private String chapter;
    private String chapterinfo;
    private String type;
    private String name;
    private String a;
    private String b;
    private String c;
    private String d;
    private String answer;
    private String level;
    private choice addchoice;
    private choiceDAO cd;
    private choice choice;
    private List<choice> choicelist;

    public choiceoperation() {
    }

    public String choicelist() throws Exception {
        cd = new choiceDAO();
        setChoicelist(cd.choicelist());
        return SUCCESS;
    }

    public String choicedelete() throws Exception {
        setCd(new choiceDAO());
        int i = getCd().deletechoice(getId());
        if (i == 1) {
            return SUCCESS;
        } else {
            return ERROR;
        }
    }

    public String choiceview() throws Exception {
        choiceDAO cd = new choiceDAO();
        setChoice(cd.getchoice(getId()));
        return SUCCESS;
    }

    public String choiceedit() throws Exception {
        choice choice = new choice();
        choice.setA(getA());
        choice.setAnswer(getAnswer());
        choice.setB(getB());
        choice.setC(getC());
        choice.setChapter(getChapter());
        choice.setD(getD());
        choice.setId(getId());
        choice.setLevel(getLevel());
        choice.setName(getName());
        choice.setSubject(getSubject());
        choice.setType(getType());
        choice.setChapterinfo(getChapterinfo());
        choiceDAO cd = new choiceDAO();
        int i = cd.editchoice(choice);
        if (i > 0) {
            return SUCCESS;
        } else {
            return INPUT;
        }
    }

    public String choiceadd() throws Exception {
        setCd(new choiceDAO());
        int i = getCd().addchoice(getAddchoice());
        if (i == 1) {
            return SUCCESS;
        } else {
            return ERROR;
        }
    }

    public String execute() throws Exception {

        return SUCCESS;

    }

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * @return the subject
     */
    public String getSubject() {
        return subject;
    }

    /**
     * @param subject the subject to set
     */
    public void setSubject(String subject) {
        this.subject = subject;
    }

    /**
     * @return the chapter
     */
    public String getChapter() {
        return chapter;
    }

    /**
     * @param chapter the chapter to set
     */
    public void setChapter(String chapter) {
        this.chapter = chapter;
    }

    /**
     * @return the chapterinfo
     */
    public String getChapterinfo() {
        return chapterinfo;
    }

    /**
     * @param chapterinfo the chapterinfo to set
     */
    public void setChapterinfo(String chapterinfo) {
        this.chapterinfo = chapterinfo;
    }

    /**
     * @return the type
     */
    public String getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(String type) {
        this.type = type;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the a
     */
    public String getA() {
        return a;
    }

    /**
     * @param a the a to set
     */
    public void setA(String a) {
        this.a = a;
    }

    /**
     * @return the b
     */
    public String getB() {
        return b;
    }

    /**
     * @param b the b to set
     */
    public void setB(String b) {
        this.b = b;
    }

    /**
     * @return the c
     */
    public String getC() {
        return c;
    }

    /**
     * @param c the c to set
     */
    public void setC(String c) {
        this.c = c;
    }

    /**
     * @return the d
     */
    public String getD() {
        return d;
    }

    /**
     * @param d the d to set
     */
    public void setD(String d) {
        this.d = d;
    }

    /**
     * @return the answer
     */
    public String getAnswer() {
        return answer;
    }

    /**
     * @param answer the answer to set
     */
    public void setAnswer(String answer) {
        this.answer = answer;
    }

    /**
     * @return the level
     */
    public String getLevel() {
        return level;
    }

    /**
     * @param level the level to set
     */
    public void setLevel(String level) {
        this.level = level;
    }

    /**
     * @return the addchoice
     */
    public choice getAddchoice() {
        return addchoice;
    }

    /**
     * @param addchoice the addchoice to set
     */
    public void setAddchoice(choice addchoice) {
        this.addchoice = addchoice;
    }

    /**
     * @return the cd
     */
    public choiceDAO getCd() {
        return cd;
    }

    /**
     * @param cd the cd to set
     */
    public void setCd(choiceDAO cd) {
        this.cd = cd;
    }

    /**
     * @return the choice
     */
    public choice getChoice() {
        return choice;
    }

    /**
     * @param choice the choice to set
     */
    public void setChoice(choice choice) {
        this.choice = choice;
    }

    /**
     * @return the choicelist
     */
    public List<choice> getChoicelist() {
        return choicelist;
    }

    /**
     * @param choicelist the choicelist to set
     */
    public void setChoicelist(List<choice> choicelist) {
        this.choicelist = choicelist;
    }
}
